<template>
    <div style="padding: 15px">
        <el-table
            v-loading="loading"
            :header-cell-style="headerCellStyle"
            :data="tableData"
            size="small"
            max-height="350px"
        >
            <el-table-column prop="name" label="皮肤包名称"></el-table-column>
            <el-table-column prop="typeName" label="皮肤包类型">
            </el-table-column>
            <el-table-column prop="terminalTypeName" label="设备类型">
            </el-table-column>
            <el-table-column prop="mustUpdate" label="是否强制升级">
                <template slot-scope="scope">
                    <div v-show="scope.row.mustUpdate === 0">不强制</div>
                    <div v-show="scope.row.mustUpdate === 1">强制</div>
                </template>
            </el-table-column>
            <el-table-column prop="createTime" label="添加日期">
                <template slot-scope="scope">{{
                    $F(scope.row.createTime)
                }}</template>
            </el-table-column>
            <el-table-column prop="updateTime" label="更新日期">
                <template slot-scope="scope">{{
                    $F(scope.row.updateTime)
                }}</template>
            </el-table-column>
            <el-table-column label="操作" fixed="right" width="75px">
                <template slot-scope="scope">
                    <el-button
                        size="mini"
                        type="primary"
                        @click="changeTheme(scope.$index, scope.row)"
                        >推送</el-button
                    >
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
export default {
    props: {
        value: Boolean,
        currRow: Object
    },
    data () {
        return {
            currentPage: 1,
            pageSize: 10,
            totalNum: 0,
            loading: false,
            tableData: [],
            showValue: false,
            terminalTypeList: [],
            packageFileTypeList: [],
            form: {
                terminalType: '',
                upgradePackageFileType: ''
            }
        }
    },
    watch: {
    },
    created () {
        this.getList()
    },
    methods: {
        search () {
            this.currentPage = 1
            this.getList()
        },
        handleCurrentChange (page) {
            // 换页
            this.currentPage = page
            this.getList()
        },
        resetPassword (row) {
            this.$confirm('确定重置密码为 syclub ?', '重置密码', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(async() => {

                            this.loading = true
            const res = await this.$http.post(this.$store.state.IP + '/upgradeManage/upgradeTaskList', {
                companyCode: this.currRow.companyCode,
                page: this.currentPage - 1,
                size: 10
            })
            let response = res.data
            if (response.ret === '0') {
                this.loading = false
                this.tableData = response.res.list
                this.totalNum = response.res.total
            } else {
                this.loading = false
            }
            
                this.$http.post(this.$store.state.IP + '/system/company/resetCompanyPsw', {
                    data: {
                        companyCode: row.companyCode,
                        managementType: this.managementType
                    }
                },
                    {
                        'emulateJSON': false
                    }
                ).then(response => {
                    response = response.body
                    console.log(response)
                    if (response.ret === '0') {
                        this.$message({
                            showClose: true,
                            message: '重置成功',
                            type: 'success'
                        })
                    }
                }, response => {
                })
            }).catch(() => {
            })
        },
        // 获取列表
        async getList () {
            this.loading = true
            const res = await this.$http.post(this.$store.state.IP + '/upgradeManage/upgradeTaskList', {
                companyCode: this.currRow.companyCode,
                page: this.currentPage - 1,
                size: 10
            })
            let response = res.data
            if (response.ret === '0') {
                this.loading = false
                this.tableData = response.res.list
                this.totalNum = response.res.total
            } else {
                this.loading = false
            }
        },
        // 清空数据
        clearData () {
            this.currentPage = 1
            this.showValue = false
            this.tableData = []
        }
    }
}
</script>
<style lang="stylus" rel="stylesheet/stylus" scoped>
.item
    width: 110px

.right
    text-align: right
</style>